package com.ljf.tijian;

import com.fasterxml.jackson.databind.ObjectMapper;

public class ApiResponse <T>{

    private Integer status;
    private String desc;
    private T data;

    public String toJOSNString(){
        String jsonStr = null;
        try{
            jsonStr = new ObjectMapper().writeValueAsString(this);
        }catch (Exception e){
            e.printStackTrace();
        }
        return jsonStr;
    }

    public ApiResponse(Integer status, String desc, T data) {
        this.status = status;
        this.desc = desc;
        this.data = data;
    }

    public ApiResponse(Integer status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public ApiResponse() {

    }


    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
